﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BaseDll;
using Communicate;
using log4net;
using SerialDict;
using MotionIoLib;
using System.Threading;
using System.ComponentModel;
namespace OtherDevice
{
    public class HesaiMsg
    {
        public string 产品序列号 { get; set; } = "SN001";
        public int 任务号 { get; set; } = 1;
        public int 标定标记 { get; set; } = 0; //标记为1 是 9点和转转中心 2为参考点示教
        public int 附带结构体数量 { get; set; } = 1;
        public List<string> 附带结构体信息 { get; set; } = new List<string>();//机械臂坐标X,机械臂坐标Y,机械臂坐标R,工位,标定序号

        public override string ToString()
        {
            string info = $"#{任务号};{标定标记};{附带结构体数量};";
            for (int i = 0; i < 附带结构体数量; i++)
            {
                info += 附带结构体信息[i];
            }
            return info;
        }
    }
    [Description("康耐视视觉")]
    public class VisionProControl:Vision_Base
    {
        public VisionProControl(string strName) : base(strName)
        {
            controlFrom = new Frm_TcpIp();
        }
        private static readonly object Lock = new object();
        public override int linkEtherNetControl()
        {
            if (link != null)
            {
                if (link.IsOpen())
                    link.Close();

            }
            link.RecvStringMessageEvent += (object sender, AsyTcpSocketEventArgs e) =>
            {
                InMessageQueue(e.Message);
            };
            link.SocketErrorEvent += (object sender, AsyTcpSocketEventArgs e) =>
            {
                return;
            };
            if (link.Open())
                return 0;
            else
                return -1;
        }

        #region 视觉算法调用
        public override int VisionControlUsing(string str_Meg, out string[] str_Result, Action actionMove = null, int nTimeout = 3000)
        {
            str_Result = new string[] { };
            return 0;

        }
        public override bool VisionExposureChange(string str_Meg, int nTimeout = 3000)
        {
            lock (Lock)
            {
                return true;
            }
        }
    }

    #endregion




}